From 8e4730fd60a1b4998d1c9c07aeb6c6a27bce210f Mon Sep 17 00:00:00 2001 From: Jonas Jelonek Date: Tue, 16 Dec 2025 10:20:13 +0000 Subject: [PATCH] realtek: mdio-serdes: improve debugfs creation Commit 3c073b5cb2 cleaned up the debugfs creation in mdio-realtek-otto-serdes driver to not explicitly check if the root directory already exists. This is fine because kernel handles the case properly so there's no need to check anymore. However, this pollutes the boot log with: [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' [..] debugfs: 'realtek_otto_serdes' already exists in '/' Now, the root directory creation is attempted multiple times, causing the kernel to print an error message because the directory already exists. Fix this by moving the SerDes loop into rtsds_debug_init and only try to create the root debugfs directory once. Signed-off-by: Jonas Jelonek Link: https://github.com/openwrt/openwrt/pull/21179 Signed-off-by: Robert Marko --- .../net/mdio/mdio-realtek-otto-serdes.c | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c index 5c8741383f..097fcc41b4 100644 --- a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c +++ b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c @@ -142,27 +142,30 @@ static int rtsds_dbg_registers_show(struct seq_file *seqf, void *unused) } DEFINE_SHOW_ATTRIBUTE(rtsds_dbg_registers); -static int rtsds_debug_init(struct rtsds_ctrl *ctrl, u32 sds) +static int rtsds_debug_init(struct rtsds_ctrl *ctrl) { struct rtsds_debug_info *dbg_info; struct dentry *dir, *root; char dirname[32]; - dbg_info = devm_kzalloc(ctrl->dev, sizeof(*dbg_info), GFP_KERNEL); - if (!dbg_info) - return -ENOMEM; - - dbg_info->ctrl = ctrl; - dbg_info->sds = sds; - root = debugfs_create_dir(RTSDS_DBG_ROOT_DIR, NULL); if (IS_ERR(root)) return PTR_ERR(root); - snprintf(dirname, sizeof(dirname), "serdes.%d", sds); - dir = debugfs_create_dir(dirname, root); + for (int sds = 0; sds < ctrl->cfg->sds_cnt; sds++) { + dbg_info = devm_kzalloc(ctrl->dev, sizeof(*dbg_info), GFP_KERNEL); + if (!dbg_info) + return -ENOMEM; - debugfs_create_file("registers", 0600, dir, dbg_info, &rtsds_dbg_registers_fops); + dbg_info->ctrl = ctrl; + dbg_info->sds = sds; + + snprintf(dirname, sizeof(dirname), "serdes.%d", sds); + dir = debugfs_create_dir(dirname, root); + + debugfs_create_file("registers", 0600, dir, dbg_info, + &rtsds_dbg_registers_fops); + } return 0; } @@ -461,8 +464,7 @@ static int rtsds_probe(struct platform_device *pdev) return ret; #ifdef CONFIG_DEBUG_FS - for (int sds = 0; sds < ctrl->cfg->sds_cnt; sds++) - rtsds_debug_init(ctrl, sds); + rtsds_debug_init(ctrl); #endif dev_info(dev, "Realtek SerDes mdio bus initialized, %d SerDes, %d pages, %d registers\n", -- 2.30.2